package 网络编程.Text;

import javax.naming.ldap.SortKey;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class TCPText1 {
    public static Scanner scanner=new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        //客户端:多次发送数据
        //服务端:接收多次数据,并打印

        //创建socket对象并连接服务端
        Socket socket=new Socket("127.0.0.1",10006);
        //写出数据
        OutputStream outputStream = socket.getOutputStream();
        //输入
        while (true) {
            System.out.print("请输入您要发送的信息:");
            String next = scanner.next();
            if (next.equals("886")){
                break;
            }
            outputStream.write(next.getBytes());
        }
        //释放资源
        socket.close();
    }
}
